package com.lixw.aiassistant.handler;

import cn.hutool.extra.spring.SpringUtil;
import lombok.Getter;

/**
 * @ClassName: ChainEnum
 * @description: 执行链枚举类
 * @author: xuweiLi
 * @create: 2025/10/13 20:40
 **/
@Getter
public enum ChainEnum {
    CUSTOMER_CHAIN("customer_chain", "RAG客户服务链", CustomerChainHandler.class),
    BUSINESS_CHAIN("business_chain", "系统业务执行链", BusinessChainHandler.class);

    private final String code;

    private final String desc;

    private final Class<? extends ChatChainHandler> chainHandlerClass;

    ChainEnum(String code, String desc, Class<? extends ChatChainHandler> chainHandlerClass) {
        this.code = code;
        this.desc = desc;
        this.chainHandlerClass = chainHandlerClass;
    }

    public ChatChainHandler getHandler(){
        return SpringUtil.getBean(chainHandlerClass);
    }

    public static ChainEnum getByCode(String code) {
        for (ChainEnum chainEnum : ChainEnum.values()) {
            if (chainEnum.code.equals(code)) {
                return chainEnum;
            }
        }
        throw new RuntimeException("找不到执行链");
    }
}
